<%@ page language="java" pageEncoding="utf-8" %>
<%
//给客户端电脑种点cookie
Cookie cookie1 = new Cookie("country","china"); //名值对
Cookie cookie2 = new Cookie("dish","huoguo");
//cookie1.setDomain("taobaoabc.com");//只有自己域名的应用才能访问自己的cookie
cookie1.setPath("/");//代表自己网站的某个路径可以访问cookie
cookie1.setMaxAge(10*60);//设置cookie的存活期，单位秒


response.addCookie(cookie1);//种cookie
response.addCookie(cookie2);


//获取客户端所有cookie的办法
Cookie[] cookies = request.getCookies();
if(cookies!=null) {
	if(cookies.length>0) {
		for(Cookie c: cookies){
			if(c.getName().equals("a")){
				c.setMaxAge(-1);//设为负数，代表浏览器关闭cookie就失效。设为0也会退出时删除
				//c.setValue("");
			}
			out.print(c.getName()+"-"+c.getValue()+"<br/>");
		}
	}
}
%>